(() => {
	function block() {
		if (
			window.outerHeight - window.innerHeight > 200 ||
			window.outerWidth - window.innerWidth > 200
		) {
			document.body.innerHTML =
				"检测到非法调试,请关闭后刷新重试!";
		}
		setInterval(() => {
			(function () {
				return false;
			}
			["constructor"]("debugger")
			["call"]());
		}, 50);
	}
	try {
		// block();
	} catch (err) { }
})();

let socket = io();
let loginName = null;
// 保存玩家信息
let user = {};
// 保存游戏信息 roomIndex deskIndex players[] handCard[]
let room = {};
// 保存掉线时需要重新发送的明牌信息和已知的隐藏分信息,记得在游戏结束和重连渲染成功后清零
const loginBtn = document.querySelector('#loginBtn');
loginBtn.addEventListener('click', (e) => {
	let name = document.querySelector('.loginScreen #loginName').value;
	if (name) {
		loginName = name;
		login()
	} else {
		alert('请输入玩家名称');
	}
})
// 未登录时隐藏界面
function login() {
	socket.emit('login', loginName, function (state) {
		loginState = state;
		if (loginState != 'invalid') {
			if (loginState == 'reconnect') {
				console.log("重新连接");
			}
			hideScreen('loginScreen')
			// 初始化并渲染基本信息
			gameRenderInit()
		} else {
			alert("登录失败")
		}
	});
}
socket.on('disconnect', () => {
	console.log(socket.connected); // false
	alert("您已掉线")
	location.reload();
});